package br.com.ufpr.sgp.pages;

import org.apache.wicket.Page;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;

//@Protected
public class ModalAlterarSenha extends ModalWindow {
    private static final long serialVersionUID = -2976050101210741474L;

    private AlterarSenhaPage alterarSenhaPage;

    public ModalAlterarSenha(final String id, final PageReference pageReference) {
        super(id);
        setCookieName("modalAlterarDadosPessoais");

        setPageCreator(new ModalWindow.PageCreator() {
            private static final long serialVersionUID = -201874349115297833L;

            public Page createPage() {
                alterarSenhaPage = new AlterarSenhaPage(ModalAlterarSenha.this, pageReference);
                return alterarSenhaPage;
            }
        });

        setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
            private static final long serialVersionUID = 7912413013403343767L;

            public void onClose(AjaxRequestTarget target) {
                ModalAlterarSenha.this.onClose(target);
            }
        });

        setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
            private static final long serialVersionUID = -9166753446792875124L;

            public boolean onCloseButtonClicked(AjaxRequestTarget target) {
                return ModalAlterarSenha.this.canClose(target);
            }
        });

        showUnloadConfirmation(false);
    }

    public void onClose(final AjaxRequestTarget target) {

    }

    public boolean canClose(final AjaxRequestTarget target) {
        return true;
    }

}
